﻿<Controls:UserControl x:Class="StockholmsStad.Windows.UI.Controls.TimeBlockControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:converter="clr-namespace:StockholmsStad.Windows.UI.Infrastructure.Converters;assembly=StockholmsStad.Windows.UI.Infrastructure"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Loaded="UserControl_Loaded"
    xmlns:Controls="clr-namespace:System.Windows.Controls;assembly=PresentationFramework">
    <UserControl.Resources>
        <converter:DateTimeToDateTimeString x:Key="DateConverter" />
        <DataTemplate x:Key="TextBlockDataTemplate">
            <TextBlock Text="{Binding StartDateTime, Converter={StaticResource DateConverter}}" TextDecorations="Underline" Background="Transparent" Width="120"/>
        </DataTemplate>
        <Style TargetType="{x:Type ListView}">
            <Setter Property="Width" Value="120" />
            <Setter Property="HorizontalAlignment" Value="Left" />
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="Height" Value="Auto" />
            <Setter Property="IsSynchronizedWithCurrentItem" Value="True" />
            <Setter Property="SelectedIndex" Value="-1" />
            <Setter Property="SelectionMode" Value="Single" />
        </Style>
        <Style x:Key="ListContainerStyle" TargetType="{x:Type ListViewItem}">
            <Setter Property="ContextMenu" Value="{DynamicResource ContextMenuKey}"></Setter>
            <Setter Property="Width" Value="100" />
            <Setter Property="FontFamily" Value="Arial"/>
            <Setter Property="FontSize" Value="12"/>
            <Setter Property="FontWeight" Value="Normal"/>
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="HorizontalAlignment" Value="Left"/>
            <Setter Property="Foreground" Value="#FF77B6EB"/>
            <!--<Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="BitmapEffect">
                        <Setter.Value>
                            <OuterGlowBitmapEffect GlowColor="Red" GlowSize="4"/>
                        </Setter.Value>
                    </Setter>
                </Trigger>
            </Style.Triggers>-->
        </Style>
    </UserControl.Resources>
    
    <StackPanel x:Name="StackPanelTimeBlocks" Visibility="Visible" Orientation="Horizontal" Height="Auto" VerticalAlignment="Top">

        <StackPanel Orientation="Vertical" Width="120"  Margin="5,0,0,0">
            <TextBlock TextWrapping="Wrap" Margin="0,2,0,5">
                        <Run Text="Välj en tid genom att klicka på aktuellt datum i listan till höger" />
            </TextBlock>
            <TextBox x:Name="TextBoxDate" Text="" IsReadOnly="True" Width="100" VerticalAlignment="Top" HorizontalAlignment="Left" />
        </StackPanel>

        <StackPanel Orientation="Vertical">

            <TabControl Grid.Column="2" Grid.RowSpan="2" SelectionChanged="ListView_SelectionChanged" Height="Auto">

                <TabItem Header="Närmast" VerticalContentAlignment="Top">

                    <ListView x:Name="listViewNearestTime" Margin="5,10,5,5" 
                                      ItemsSource="{Binding}" ItemContainerStyle="{StaticResource ListContainerStyle}"
                                      ItemTemplate="{StaticResource TextBlockDataTemplate}">
                    </ListView>

                </TabItem>

                <TabItem Header="Alla" VerticalContentAlignment="Top">

                    <ListView x:Name="listViewAllTimes" Margin="5,10,5,5" 
                                      ItemsSource="{Binding}" ItemContainerStyle="{StaticResource ListContainerStyle}"
                                      IsSynchronizedWithCurrentItem="True" ItemTemplate="{StaticResource TextBlockDataTemplate}">
                    </ListView>

                </TabItem>

            </TabControl>
        </StackPanel>
    </StackPanel>
</Controls:UserControl>
